﻿using System;
using System.Data.SQLite;
using System.IO;
using Dapper;

namespace pinduoduo.Util
{
    public static class DataBaseHelper
    {
        static DataBaseHelper()
        {
            DefaultTypeMap.MatchNamesWithUnderscores = true;
        }

        //public abstract IDbConnection GetConnection();
        //protected static string GetConnectionString(string name, string defaultConnectionString) =>
        //    Environment.GetEnvironmentVariable(name) ?? defaultConnectionString;
        //private IDbConnection GetOpenConnection()
        //{
        //    var connection = GetConnection();
        //    connection.Open();
        //    return connection;
        //}

        public static SQLiteConnection SqLiteDBCon
        {
            get
            {
                SQLiteConnectionStringBuilder sb = new SQLiteConnectionStringBuilder();

                string dbpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data.db");
                
                sb.DataSource = dbpath;
                SQLiteConnection con = new SQLiteConnection(sb.ToString());
                return con;
            }
        }
 
    }
}
